#include<stdio.h>
#include<stdlib.h>

void my_mv(char filename1[],char filename2[])
{
	FILE *fp;
	if((fp=fopen(filename1,"r"))==NULL)
	{
		perror("fopen error");
		exit(0);
	}
	else
	{
		printf("open %s succeed!\n",filename1);
		fclose(fp);
		if(rename(filename1,filename2)==0)
		{
			printf("Rename the file %s succeed!\n",filename1);
		}
		else
		{
			printf("Cannot rename the file %s!\n",filename1);
		}
	}
}

int main(int argc,char *argv[])
{
	if(argc < 3)
    {
        fprintf(stderr, "%s <oldname> <newname>:\n", argv[0]);
        exit(1);
    }
	my_mv(argv[1],argv[2]);
	
	return 0;
}

